// phalanx integral_constant.hpp.cu header file

// Copyright (c) 2010 - 2011 Kohei Takahashi (Flast).
// Distributed under the MIT license. for more detail see COPYING.

// Redefinition std::integral_constant (C++0x's)
//              std::true_type (C++0x's)
//              std::false_type (C++0x's)


#ifndef IG_PHALANX_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP_CU_ONCE_
#define IG_PHALANX_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP_CU_ONCE_

#include <phalanx/config.hpp.cu>

#include <phalanx/type_traits/detail/safe_bool.hpp.cu>

namespace phalanx
{

template < typename T, T x >
struct integral_constant
{
    static const T value = x;

    typedef T                         value_type;
    typedef integral_constant< T, x > type;

    PHALANX_CONFIG_DEFAULT_FUNCTION( true )
    operator T( void ) const
    { return value; }
};

template <>
struct integral_constant< bool, true >
{
    static const bool value = true;

    typedef bool                            value_type;
    typedef integral_constant< bool, true > type;

    PHALANX_CONFIG_DEFAULT_FUNCTION( true )
    operator safe_bool_detail::safe_bool( void ) const
    { return safe_bool_detail::safe_bool_impl::true_(); }
};

template <>
struct integral_constant< bool, false >
{
    static const bool value = false;

    typedef bool                             value_type;
    typedef integral_constant< bool, false > type;

    PHALANX_CONFIG_DEFAULT_FUNCTION( true )
    operator safe_bool_detail::safe_bool( void ) const
    { return safe_bool_detail::safe_bool_impl::false_(); }
};

typedef integral_constant< bool, true >  true_type;
typedef integral_constant< bool, false > false_type;

} // namespace phalanx

#endif // IG_PHALANX_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP_CU_ONCE_

